package com.easy.util;

import lombok.Data;

@Data
public class Page {
    private Integer page;//页码
    private Integer limit;//每页显示的条数
    private Integer start;//数据库查询的起始索引
    
    public Integer getPage() {
        return page == null || page < 1 ? 1 : page;
    }
    
    public Integer getLimit() {
        return limit == null ? 10 : limit;
    }
    
    public Integer getStart(){
        return (getPage() - 1) * getLimit();
    }
    
    public void setPage(Integer page) {
        this.page = page;
    }
    
    public void setLimit(Integer limit) {
        this.limit = limit;
    }
    
    public void setStart(Integer start) {
        this.start = start;
    }
    
    private Integer count;//表中数据总条数
    private Object data;
    
    // 添加分页相关字段，与XML映射文件中的参数保持一致
    public Integer getCount() {
        return count;
    }
    
    public Integer getTotalCount() {
        return count;
    }
    
    public void setCount(Integer count) {
        this.count = count;
    }
    
    public void setTotalCount(Integer count) {
        this.count = count;
    }
    
    public Object getData() {
        return data;
    }
    
    public Object getList() {
        return data;
    }
    
    public void setData(Object data) {
        this.data = data;
    }
    
    public void setList(Object data) {
        this.data = data;
    }
    
    // 添加startIndex和pageSize属性以匹配XML中的参数引用
    public Integer getStartIndex() {
        return getStart();
    }
    
    public Integer getPageSize() {
        return getLimit();
    }
}